package com.cictec.middleware.gps.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cictec.middleware.commons.cache.ecache.EHCacheUtils;
import com.cictec.middleware.commons.utils.ZoneUtils;
import com.cictec.middleware.core.entity.BusLineStation;
import com.cictec.middleware.gps.service.feign.MiddlewareDcFeignClient;
import com.vividsolutions.jts.geom.Geometry;

/**
 * 线路信息-站点信息service
 * @author ql
 *
 */
@Service
public class BusLineStataionService {

	public static Logger logger = LoggerFactory.getLogger(BusLineStataionService.class);

	
	public BusLineStation getLineStationByStationSeq(List<BusLineStation> stationList, int stationSeq) {
		BusLineStation station = null;
		for (BusLineStation lineStation : stationList) {
			if (lineStation.getLsSequence() == stationSeq) {
				station = lineStation;
				break;
			}
		}
		return station;
	}
	

	public Map<String, List<Geometry>> initLineStationsGeometry(Map<String, List<BusLineStation>> busLineStationMap) {
		// TODO Auto-generated method stub
		Map<String, List<Geometry>> map = new HashMap<String, List<Geometry>>();
		for (String lineType : busLineStationMap.keySet()) {
			List<Geometry> stationGeometryList = new ArrayList<Geometry>();
			for (BusLineStation busLineStation : busLineStationMap.get(lineType)) {
				stationGeometryList.add(ZoneUtils.createCircleBufferGeometry(busLineStation.getLsStaLat(), busLineStation.getLsStaLng()));
			}
			map.put(lineType, stationGeometryList);
		}
		
		return map;
		
	}
	
}
